package zhoug.common.permission;

import android.content.Context;

import zhoug.common.view.dialog.ZButtonDialog;

import java.util.List;
import java.util.Locale;

import androidx.annotation.NonNull;

/**
 * @Author 35574
 * @Date 2021/6/7
 * @Description
 */
class NotAskingPermissionDialog implements INotAskingPermissionDialog {

    @Override
    public void show(Context context, @NonNull List<String> notAskingPermissions, @NonNull Callback callback) {
        String message = String.format(Locale.CANADA, "本应用缺少%s权限\n\n请到设置-应用权限中打开所需权限,否则可能不能正常使用", MUtils.getNames(notAskingPermissions));
        ZButtonDialog buttonDialog = new ZButtonDialog(context);
        buttonDialog.setTitle("授权");
        buttonDialog.setMessage(message);
        buttonDialog.setPositiveListener("设置", v -> {
            buttonDialog.dismiss();
            callback.onConfirm();
        });
        buttonDialog.setNegativeListener("取消", v -> {
            buttonDialog.dismiss();
            callback.onCancel();
        });
        buttonDialog.setCancelable(false);
        buttonDialog.show();
    }


}
